<?php
use app\models\User;
use app\models\UserProfile;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;

/* @var $model \app\models\UserProfile */
/* @var $user \app\models\User */
/* @var $this \yii\web\View */
/* @var $type String */

\app\assets\MuiPickerAsset::register($this);

$fieldLabels = [
    'uname' => [
        User::TYPE_STUDENT => '请输入姓名',
        User::TYPE_ORG => '请输入组织名称',
        User::TYPE_COMPANY => '请输入企业名称',
    ],
    'experience1' => [
        User::TYPE_STUDENT => '自我介绍',
        User::TYPE_ORG => '基本信息',
        User::TYPE_COMPANY => '基本信息',
    ],
    'experience2' => [
        User::TYPE_STUDENT => '赛事经历',
        User::TYPE_ORG => '组织介绍',
        User::TYPE_COMPANY => '公司介绍',
    ],
    'experience3' => [
        User::TYPE_STUDENT => '志愿者经历',
        User::TYPE_ORG => '详情介绍',
        User::TYPE_COMPANY => '详情介绍',
    ],
    'experience4' => [
        User::TYPE_STUDENT => '兼职经历',
        User::TYPE_ORG => '风貌展示',
        User::TYPE_COMPANY => '风貌展示',
    ],
    'experience5' => [
        User::TYPE_STUDENT => '实习经历',
        User::TYPE_ORG => '发展历程',
        User::TYPE_COMPANY => '发展历程',
    ],
];

?>

<div class="mui-content">

    <div class="edit-form">
        <?php $form = ActiveForm::begin(['options' => ['class' => 'mui-input-group']]); ?>

        <div class="ui-form-item ui-border-b">
            <div class="mui-input-row">
                <label></label>
                <?= $form->field($user, 'uname')->textInput(['placeholder' => $fieldLabels['uname'][$user->type]])->label(FALSE); ?>
            </div>
        </div>

        <?php if (!$user->getIsStudent()): ?>
            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'company_code')->textInput(['placeholder' => '请输入统一信用代码'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'industry')->textInput( ['placeholder' => '请选择公司行业', 'readonly' => 'readonly', 'class' => 'industry form-control'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'company_scale')->textInput(['placeholder' => '请选择公司规模', 'readonly' => 'readonly', 'class' => 'company_scale form-control'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'province')->textInput(['placeholder' => '选择省份', 'readonly' => 'readonly', 'class' => 'province form-control'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'city')->textInput(['placeholder' => '选择城市', 'readonly' => 'readonly', 'class' => 'city form-control'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'address')->textInput(['placeholder' => '请输入详细地址'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'home_link')->textInput(['placeholder' => '请输入官网链接'])->label(FALSE); ?>
            </div>
        <?php endif; ?>

        <?php if ($user->getIsStudent()): ?>
            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'sex')->dropDownList(User::$sexLabels)->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'school')->textInput(['placeholder' => '请输入学校名称'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'major')->textInput(['placeholder' => '请输入专业'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'school_time')->textInput(['placeholder' => '请选择入学时间', 'class' => 'datetime form-control'])->label(FALSE); ?>
            </div>

            <div class="mui-input-row">
                <label></label>
                <?= $form->field($model, 'wechat')->textInput(['placeholder' => '请输入微信号'])->label(FALSE); ?>
            </div>
        <?php endif; ?>

        <div class="mui-input-row">
            <label></label>
            <?= $form->field($user, 'phone')->textInput(['placeholder' => '请输入联系电话'])->label(FALSE); ?>
        </div>

        <div class="mui-input-row">
            <label></label>
            <?= $form->field($model, 'email')->textInput(['placeholder' => '请输入电子邮箱'])->label(FALSE); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label><?= $fieldLabels['experience1'][$user->type]; ?>
            </div>
            <?= $form->field($model, 'experience1')->textarea(['rows' => 5])->label(FALSE); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label><?= $fieldLabels['experience2'][$user->type]; ?>
            </div>
            <?= $form->field($model, 'experience2')->textarea(['rows' => 5])->label(FALSE); ?>
        </div>

        <?php if ($user->getIsStudent()): ?>
        <div class="mui-textarea-row">
            <div class="title">
                <label></label><?= $fieldLabels['experience3'][$user->type]; ?>
            </div>
            <?= $form->field($model, 'experience3')->textarea(['rows' => 5])->label(FALSE); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label><?= $fieldLabels['experience4'][$user->type]; ?>
            </div>
            <?= $form->field($model, 'experience4')->textarea(['rows' => 5])->label(FALSE); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label><?= $fieldLabels['experience5'][$user->type]; ?>
            </div>
            <?= $form->field($model, 'experience5')->textarea(['rows' => 5])->label(FALSE); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label>上传获取证书
            </div>
            <?= $this->render('/upload/index', [
                'name' => 'user_images',
                'thumbs' => $model->getThumbsByFiled('user_images'),
                'original_name' => 'original_user_images'
            ]); ?>
        </div>
        <?php endif; ?>

        <?php if(!$user->getIsStudent()): ?>
        <div class="mui-textarea-row">
            <div class="title">
                <label></label>上传副本照片
            </div>
            <?= $this->render('/upload/index', [
                'name' => 'identity_images',
                'thumbs' => $model->getThumbsByFiled('identity_images'),
                'original_name' => 'original_identity_images'
            ]); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label>风貌展示
            </div>
            <?= $this->render('/upload/index', [
                'name' => 'style_images',
                'thumbs' => $model->getThumbsByFiled('style_images'),
                'original_name' => 'original_style_images'
            ]); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label>产品展示
            </div>
            <?= $this->render('/upload/index', [
                'name' => 'product_images',
                'thumbs' => $model->getThumbsByFiled('product_images'),
                'original_name' => 'original_product_images'
            ]); ?>
        </div>

        <div class="mui-textarea-row">
            <div class="title">
                <label></label>上传负责人证明
            </div>
            <?= $this->render('/upload/index', [
                'name' => 'user_images',
                'thumbs' => $model->getThumbsByFiled('user_images'),
                'original_name' => 'original_user_images'
            ]); ?>
        </div>
        <?php endif; ?>

        <button data-redirect="<?= Url::to(['user/index']); ?>" type="submit" class="mui-btn btn-ui mui-btn-block border-r5">保存</button>

        <?php ActiveForm::end(); ?>
    </div>
</div>

<?= \app\widgets\WxJsWidget::widget([]); ?>
